<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Contentful  Reference</title>
    <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="css/highlight.css" />
    <meta charset='utf-8'>
    <script src="js/jquery.min.js" defer></script>
    <script src="js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a title="Contentful  Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="index.html">Contentful Docs</a> (72% documented)</p>
        <p class="header-right"><a href="https://github.com/contentful/contentful.swift"><img src="img/gh.png"/>View on GitHub</a></p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="index.html">Contentful Reference</a>
        <img id="carat" src="img/carat.png" />
        Contentful  Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Classes/Asset.html">Asset</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/Asset/FileMetadata.html">– FileMetadata</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/AssetQuery.html">AssetQuery</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/Client.html">Client</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes.html#/s:C10Contentful12ContentModel">ContentModel</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/ContentType.html">ContentType</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/ContentfulError.html">ContentfulError</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes.html#/s:C10Contentful5Entry">Entry</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/FilterQuery.html">FilterQuery</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/Locale.html">Locale</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/LocalizableResource.html">LocalizableResource</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes.html#/s:C10Contentful19LocalizationContext">LocalizationContext</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/Query.html">Query</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/QueryOn.html">QueryOn</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/RateLimitError.html">RateLimitError</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/Resource.html">Resource</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/Space.html">Space</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/SyncSpace.html">SyncSpace</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/SysISO8601DateTransform.html">SysISO8601DateTransform</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Enums.html">Enums</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Enums/Bounds.html">Bounds</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/FieldType.html">FieldType</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/Fit.html">Fit</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/Focus.html">Focus</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/Format.html">Format</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/ImageOption.html">ImageOption</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/JPGQuality.html">JPGQuality</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/Link.html">Link</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/MimetypeGroup.html">MimetypeGroup</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/QueryError.html">QueryError</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/QueryOperation.html">QueryOperation</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/SDKError.html">SDKError</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Extensions/Date.html">Date</a>
              </li>
              <li class="nav-group-task">
                <a href="Extensions/Date/Formatter.html">– Formatter</a>
              </li>
              <li class="nav-group-task">
                <a href="Extensions/Dictionary.html">Dictionary</a>
              </li>
              <li class="nav-group-task">
                <a href="Extensions/Int.html">Int</a>
              </li>
              <li class="nav-group-task">
                <a href="Extensions/String.html">String</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Functions.html">Functions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Functions.html#/s:F10Contentfuloi2eeFTCS_8ResourceS0__Sb">==(_:_:)</a>
              </li>
              <li class="nav-group-task">
                <a href="Functions.html#/s:F10Contentfuloi2eeFTOS_11ImageOptionS0__Sb">==(_:_:)</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Protocols/AbstractQuery.html">AbstractQuery</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/ChainableQuery.html">ChainableQuery</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/ContentModellable.html">ContentModellable</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/EntryModellable.html">EntryModellable</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/Integration.html">Integration</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/PersistenceIntegration.html">PersistenceIntegration</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/QueryableRange.html">QueryableRange</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/SpaceModellable.html">SpaceModellable</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Structs.html">Structs</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Structs/ArrayResponse.html">ArrayResponse</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/ClientConfiguration.html">ClientConfiguration</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/Field.html">Field</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/LinkSys.html">LinkSys</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/MappedArrayResponse.html">MappedArrayResponse</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/MappedContent.html">MappedContent</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/OrderParameter.html">OrderParameter</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs.html#/s:V10Contentful14QueryParameter">QueryParameter</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/Sys.html">Sys</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Typealiases.html">Typealiases</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Typealiases.html#/s:10Contentful14ResultsHandler">ResultsHandler</a>
              </li>
              <li class="nav-group-task">
                <a href="Typealiases.html#/s:10Contentful14TaskObservable">TaskObservable</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            
            <h1 id='contentful-swift' class='heading'>contentful.swift</h1>

<p><a href="http://cocoadocs.org/docsets/Contentful"><img src="https://img.shields.io/cocoapods/v/Contentful.svg?style=flat" alt="Version"></a>
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible"></a>
<a href="http://cocoadocs.org/docsets/Contentful"><img src="https://img.shields.io/cocoapods/p/Contentful.svg?style=flat" alt="Platform"></a>
<a href="http://cocoadocs.org/docsets/Contentful"><img src="https://img.shields.io/cocoapods/l/Contentful.svg?style=flat" alt="License"></a>
<a href="https://travis-ci.org/contentful/contentful.swift"><img src="https://img.shields.io/travis/contentful/contentful.swift/master.svg?style=flat" alt="Build Status"></a>
<a href="https://coveralls.io/github/contentful/contentful.swift"><img src="https://img.shields.io/coveralls/contentful/contentful.swift.svg" alt="Coverage Status"></a>
<a href="https://codebeat.co/projects/github-com-contentful-contentful-swift"><img src="https://codebeat.co/badges/6ebc67e8-29ca-459f-a4b7-b32a84fa9074" alt="codebeat badge"></a></p>

<p>Swift SDK for <a href="https://www.contentful.com">Contentful&rsquo;s</a> Content Delivery API.</p>

<p><a href="https://www.contentful.com">Contentful</a> is a content management platform for web applications, mobile apps and connected devices. It allows you to create, edit &amp; manage content in the cloud and publish it anywhere via powerful API. Contentful offers tools for managing editorial teams and enabling cooperation between organizations.</p>

<p>The Contentful Swift SDK hasn&rsquo;t reached 1.0.0 and is therefore subject to API changes. However, it provides a more usable API than the <a href="https://github.com/contentful/contentful.objc">Objective-C SDK</a> and has support for more API features. It is recommended to use contentful.swift over contentful.objc as future development at Contentful will focus on Swift rather than Objective-C. However, if your project must utilize Contentful&rsquo;s <a href="https://www.contentful.com/developers/docs/references/content-management-api/">Content Managamement API</a>, Objective-C is the only  language supported at the moment. See <a href="https://cocoapods.org/pods/ContentfulManagementAPI">ContentfulManagementAPI at Cocoapods.org</a> for more information.</p>
<h4 id='full-feature-comparison-of-a-href-https-github-com-contentful-contentful-swift-tree-swift-2-3-contentful-swift-a-amp-a-href-https-github-com-contentful-contentful-objc-contentful-objc-a' class='heading'>Full feature comparison of <a href="https://github.com/contentful/contentful.swift/tree/Swift-2.3">contentful.swift</a> &amp; <a href="https://github.com/contentful/contentful.objc">contentful.objc</a></h4>

<table><thead>
<tr>
<th>CDA Features</th>
<th><a href="https://github.com/contentful/contentful.swift">contentful.swift</a></th>
<th><a href="https://github.com/contentful/contentful.objc">contentful.objc</a></th>
</tr>
</thead><tbody>
<tr>
<td>API coverage*</td>
<td>:white_check_mark:</td>
<td>:white_check_mark:</td>
</tr>
<tr>
<td>Images API</td>
<td>:white_check_mark:</td>
<td>:white_check_mark:</td>
</tr>
<tr>
<td>Search Parameters</td>
<td>:white_check_mark:</td>
<td>:no_entry_sign:</td>
</tr>
<tr>
<td>Fallback locales for sync api</td>
<td>:white_check_mark:</td>
<td>:no_entry_sign:</td>
</tr>
<tr>
<td>Rate limit handling</td>
<td>:white_check_mark:</td>
<td>:no_entry_sign:</td>
</tr>
</tbody></table>

<p>*API Coverage definition: all endpoints can be interfaced with and complex queries can be constructed by passing in dictionaries of http parameter/argument pairs. Note that the Swift SDK provides much more comprehensive coverage and takes advantage of type system, outdoing the <q>stringly typed</q> interface that the Objective-C SDK offers.</p>
<h2 id='usage' class='heading'>Usage</h2>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">client</span> <span class="o">=</span> <span class="kt">Client</span><span class="p">(</span><span class="nv">spaceId</span><span class="p">:</span> <span class="s">"cfexampleapi"</span><span class="p">,</span> <span class="nv">accessToken</span><span class="p">:</span> <span class="s">"b4c0n73n7fu1"</span><span class="p">)</span>
<span class="n">client</span><span class="o">.</span><span class="nf">fetchEntry</span><span class="p">(</span><span class="s">"nyancat"</span><span class="p">)</span> <span class="p">{</span> <span class="p">(</span><span class="nv">result</span><span class="p">:</span> <span class="kt">Result</span><span class="o">&lt;</span><span class="kt">Entry</span><span class="o">&gt;</span><span class="p">)</span> <span class="k">in</span>
    <span class="k">switch</span> <span class="n">result</span> <span class="p">{</span>
        <span class="k">case</span> <span class="o">.</span><span class="nf">success</span><span class="p">(</span><span class="n">entry</span><span class="p">):</span>
            <span class="nf">print</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
        <span class="k">case</span> <span class="o">.</span><span class="nf">error</span><span class="p">(</span><span class="k">let</span> <span class="nv">error</span><span class="p">):</span>
            <span class="nf">print</span><span class="p">(</span><span class="s">"Error </span><span class="se">\(</span><span class="n">error</span><span class="se">)</span><span class="s">!"</span><span class="p">)</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre>
<h2 id='code-contentmodellable-code-and-code-mappedcontent-code-beta' class='heading'><code>ContentModellable</code> and <code>MappedContent</code> (beta)</h2>

<p>The <code>ContentModellable</code> and <code>EntryModellable</code> protocols allows you to define types that will be mapped from <code>Entry</code>s of the various content types in your Contentful space. When using methods such as:</p>
<pre class="highlight plaintext"><code>func fetchMappedEntries(with query: Query) -&gt; Observable&lt;Result&lt;MappedContent&gt;&gt;
</code></pre>

<p>the asynchronously returned result will be an instance of <code>MappedContent</code> which will contain a dictionary which maps content type identifiers to arrays of <code>EntryModellable</code> (types of your own definition) that have been fetched. Note that these features are in beta and the API is subject to change.</p>
<h2 id='reference-documentation' class='heading'>Reference Documentation</h2>

<p>For further information about the API, check out the <a href="https://www.contentful.com/developers/documentation/content-delivery-api/">Content Delivery API Reference Documentation</a>.</p>
<h2 id='swift-versioning' class='heading'>Swift Versioning</h2>

<p>The Contentful Swift SDK requires, at minimum, Swift 2.2 and therefore Xcode 7.3.</p>

<table><thead>
<tr>
<th>Swift version</th>
<th>Compatible Contentful tag</th>
</tr>
</thead><tbody>
<tr>
<td>Swift 3.0</td>
<td>[<code>0.3.0</code> - <code>0.8.0</code>]</td>
</tr>
<tr>
<td>Swift 2.3</td>
<td><code>0.2.3</code></td>
</tr>
<tr>
<td>Swift 2.2</td>
<td><code>0.2.1</code></td>
</tr>
</tbody></table>

<p>While there have been some patches applied to the <a href="https://github.com/contentful/contentful.swift/tree/Swift-2.3"><code>Swift-2.3</code> branch</a>, no future maintainence is intended on this branch. It is recommended to upgrade to Swift 3 and
use the newest version of contentful.swift.</p>
<h3 id='cocoapods-installation' class='heading'>CocoaPods installation</h3>

<p><a href="http://www.cocoapods.org">CocoaPods</a> is a dependency manager for Swift, which automates and simplifies the process of using 3rd-party libraries like the Contentful Delivery API in your projects.</p>
<pre class="highlight ruby"><code><span class="n">platform</span> <span class="ss">:ios</span><span class="p">,</span> <span class="s1">'8.0'</span>
<span class="n">use_frameworks!</span>
<span class="n">pod</span> <span class="s1">'Contentful'</span>
</code></pre>

<p>You can specify a specific version of Contentful depending on your needs. To learn more about operators for dependency versioning within a Podfile, see the <a href="https://guides.cocoapods.org/using/the-podfile.html">CocoaPods doc on the Podfile</a>.</p>
<pre class="highlight ruby"><code><span class="n">pod</span> <span class="s1">'Contentful'</span><span class="p">,</span> <span class="s1">'~&gt; 0.8.0'</span> 
</code></pre>

<p>Note that for Swift 2.3 support (contentful.swift <code>v0.2.3</code>) you will need to add a post-install script to your Podfile if installing with Cocoapods:</p>
<pre class="highlight ruby"><code><span class="n">post_install</span> <span class="k">do</span> <span class="o">|</span><span class="n">installer</span><span class="o">|</span>
  <span class="n">installer</span><span class="p">.</span><span class="nf">pods_project</span><span class="p">.</span><span class="nf">targets</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">target</span><span class="o">|</span>
    <span class="n">target</span><span class="p">.</span><span class="nf">build_configurations</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
      <span class="n">config</span><span class="p">.</span><span class="nf">build_settings</span><span class="p">[</span><span class="s1">'SWIFT_VERSION'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'2.3'</span>
    <span class="k">end</span>
  <span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h3 id='carthage-installation' class='heading'>Carthage installation</h3>

<p>You can also use <a href="https://github.com/Carthage/Carthage">Carthage</a> for integration by adding the following to your <code>Cartfile</code>:</p>
<pre class="highlight plaintext"><code>github "contentful/contentful.swift" ~&gt; 0.8.0
</code></pre>
<h2 id='license' class='heading'>License</h2>

<p>Copyright &copy; 2016 Contentful GmbH. See LICENSE for further details.</p>

          </section>
        </section>
        <section id="footer">
          <p>&copy; 2017 <a class="link" href="https://www.contentful.com" target="_blank" rel="external">Contentful</a>. All rights reserved. (Last updated: 2017-07-31)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
